//
//  AftermarketVC.m
//  BigJoy
//
//  Created by Rowling on 2017/7/11.
//  Copyright © 2017年 Rowling. All rights reserved.
//

#import "AftermarketVC.h"
#import "XMIndexHeaderView.h"
#import "WaitDispatchCell.h"
#import "OrderDetailVC.h"

@interface AftermarketVC ()<XMIndexHeaderViewDelegate>
@property (weak, nonatomic) IBOutlet UIView *headerContentView;
@property (weak, nonatomic) IBOutlet UIView *tableContentView;
@property (weak, nonatomic) IBOutlet UIButton *allButton;
@property (weak, nonatomic) IBOutlet UIButton *dealButton;
@property (weak, nonatomic) IBOutlet UIButton *backGoodsButton;
@property (weak, nonatomic) IBOutlet UIButton *refuseButton;
@property (nonatomic,strong) NSArray *buttonArray;
@end

@implementation AftermarketVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.buttonArray = @[self.allButton,self.dealButton,self.backGoodsButton,self.refuseButton];
    [self.tableContentView addSubview:self.XMTableview];
    [self.XMTableview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.equalTo(self.tableContentView);
    }];
    self.XMTableview.estimatedRowHeight = 240;
    
}

-(void)viewWillAppear:(BOOL)animated {
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    XMIndexHeaderView * indexView = [[XMIndexHeaderView alloc]initWithFrame:CGRectMake(0, 0, XMW(209), 44) WithTitleArray:@[@"退款",@"退货",@"换货"] animation:NO];
    indexView.centerX = SCREEN_WIDTH / 2;
    indexView.delegateXM = self;
    [_headerContentView addSubview:indexView];
}


-(void)viewWillDisappear:(BOOL)animated {
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}


// xmindex 按钮点击
-(void)XMIndexHeaderViewDidselectedWithIndex:(NSInteger)index {
    
}
// index按钮点击
- (IBAction)buttonClick:(UIButton *)sender {
    for (UIButton * btn in self.buttonArray) {
        btn.selected = NO;
    }
    sender.selected = YES;
}

- (IBAction)backButtonClick:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    WaitDispatchCell * cell = [WaitDispatchCell cellWithTalbelView:tableView];
    cell.cellType = WaiteDispath;
    cell.count = indexPath.row + 1;
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return UITableViewAutomaticDimension;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    OrderDetailVC * vc = [OrderDetailVC new];
    [self.navigationController pushViewController:vc animated:YES];
}

@end
